import i18n from "i18next";
import { initReactI18next } from "react-i18next";

import en from "./locales/en-us.json";
import cn from "./locales/zh-cn.json";
export type Keys = keyof typeof en;

export enum Language {
  EN = "en-US",
  CN = "zh-CN",
}

export const resources = {
  [Language.EN]: {
    translation: en,
  },
  [Language.CN]: {
    translation: cn,
  },
};

i18n.use(initReactI18next).init({
  resources, // 添加资源
  partialBundledLanguages: true,
  ns: [],
  defaultNS: "",
  load: "currentOnly",
  lng: Language.CN, // 默认语言
  fallbackLng: Language.CN, // 回退语言
  interpolation: {
    escapeValue: false,
  },
  nsSeparator: ".",
  detection: {
    // caches: ["localStorage"],
  },
});

export default i18n;
